gh-141617: Add missing result() call in concurrent.futures example#141620
gh-141617: Add missing result() call in concurrent.futures example#141620Yashp002 wants to merge 4 commits intopython:mainfrom
Conversation
picnixz
left a comment
There was a problem hiding this comment.
The other place where to add the comment was after b = executor.submit(wait_on_a) just a few lines above not in the documentation for submit.
Doc/library/concurrent.futures.rst
Outdated
| # Note: calling future.result() outside this with statement would work fine, | ||
| # but calling it here is safe because we print it immediately and the executor | ||
| # can complete the task before the context manager exits. |
There was a problem hiding this comment.
This comment is incorrect. It's not for this example that we needed to add this comment.
Doc/library/concurrent.futures.rst
Outdated
| executor = ThreadPoolExecutor(max_workers=1) | ||
| executor.submit(wait_on_future) | ||
|
|
||
| executor.submit(wait_on_future).result() |
There was a problem hiding this comment.
We should not call .result(). We should indicate in the comment that calling .result would produce a deadlock.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
I have made the requested changes; please review again |
|
Thanks for making the requested changes! @picnixz: please review the changes made to this pull request. |
|
Hi @picnixz Just checking in on this PR. I'm happy to address any remaining feedback or make changes as needed. Please let me know if there's anything I should update. Thanks. |
This PR fixes an incomplete code example in the concurrent.futures documentation.
The second example in the deadlock section was missing a
.result()call on the executor.submit() invocation, which is necessary to demonstrate the deadlock behavior described in the comment.Changes:
.result()call to complete the example in Doc/library/concurrent.futures.rstFixes #141617
📚 Documentation preview 📚: https://cpython-previews--141620.org.readthedocs.build/